package com.shop.cereshop.app.page.product;
import cn.hutool.core.date.DateUtil;
import com.shop.cereshop.commons.domain.calculate.Calculate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Data
@ApiModel(value = "ProductDetailSimple", description = "商品简要信息")
public class ProductDetailSimple {

    /**
     * 商品id
     */
    @ApiModelProperty(value = "商品id")
    private Long productId;

    /**
     * 店铺id
     */
    @ApiModelProperty(value = "店铺id")
    private Long shopId;

    /**
     * 商品名称
     */
    @ApiModelProperty(value = "商品名称")
    private String productName;

    /**
     * 商品简介
     */
    @ApiModelProperty(value = "商品简介")
    private String productBrief;

    /**
     * skuId
     */
    @ApiModelProperty(value = "skuId")
    private Long skuId;

    /**
     * 商品原价
     */
    @ApiModelProperty(value = "商品原价")
    private BigDecimal originalPrice;

    /**
     * 售价
     */
    @ApiModelProperty(value = "售价")
    private BigDecimal price;

    /**
     * 商品图片
     */
    @ApiModelProperty(value = "商品图片")
    private String image;

    /**
     * 规格名称
     */
    @ApiModelProperty(value = "规格名称")
    private String skuName;

    /**
     * 规格值
     */
    @ApiModelProperty(value = "规格值")
    private String skuValue;

    /**
     * 销量
     */
    @ApiModelProperty(value = "销量")
    private Integer salesVolume;



    /**
     * 店铺标签
     */
    @ApiModelProperty(value = "店铺标签")
    private List<String> shopTags;

    /**
     * 商品评分
     */
    @ApiModelProperty(value = "商品评分")
    private Integer productScore;

    /**
     * 商品标签
     */
    @ApiModelProperty(value = "商品标签")
    private List<String> productLabels;


    public void setProductLabels(Calculate calculate) {

        List<String> list = new ArrayList<>();

        if (calculate.getShopAllWeekToUer() != null && 1 == calculate.getShopAllWeekToUer()) {
            list.add("全周可用");
        }
        if (calculate.getShopGoodLikeWater() != null && 1 == calculate.getShopGoodLikeWater()) {
            list.add("好评如潮");
        }
        if (calculate.getHotProduct() != null && 1 == calculate.getHotProduct()) {
            list.add("热销商品");
        }
        if (calculate.getPriceGood()!= null && 1 == calculate.getPriceGood()){
            list.add("价格实惠");
        }


        this.productLabels = list;
    }

    /**
     * 商品创建时间
     */
    @ApiModelProperty(value = "商品创建时间")
    private String createTime;

    @ApiModelProperty(value = "商品创建时间")
    private Long currentTime;

    public void setCreateTime(String createTime) {
        this.currentTime = DateUtil.parse(createTime, "yyyy-MM-dd HH:mm:ss").getTime();
    }


}


